#include "base.h"

namespace CoreBase
{
	Base::Base(const QString& name) : _name(name),_id("")
	{}

	Base::~Base()
	{}

	void Base::setName(const QString& name)
	{
	   _name = name;
	}

	const QString& Base::getName() const
	{
	   return _name;
	}

	void Base::addSender(Base* sender)
	{
		QObject::connect(sender,SIGNAL(emitSignals(MessageData*)),this,SLOT(onMessage(MessageData*)));
	}

	void Base::removeSender(Base* sender)
	{
		QObject::disconnect(sender,SIGNAL(emitSignals(MessageData*)),this,SLOT(onMessage(MessageData*)));
	}

	void Base::sendMessage(const QString& message, void* data)
	{
	   //make a new MessageData, load it up, and pass it to our signal
	   MessageData dataToSend;
	   dataToSend.message = message;
	   dataToSend.sender = this;
	   dataToSend.userData = data;
	   emit emitSignals(&dataToSend);
	}
}